package com.dc.commons.config.web;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletException;

import org.springframework.core.annotation.Order;
import org.springframework.web.context.ContextLoaderListener;

import com.dc.commons.config.mvc.WebMvcConfig;
import com.dc.commons.config.root.RootConfig;
import com.dc.commons.config.web.context.ContextLoaderListenerWrapper;
import com.dc.commons.config.web.context.ContextLoaderListenerWrapperAdpater;

/*******************************************************************************<P>
 * 文件名: WebInitializer.java <br>
 * 版本: 1.0<br>
 * 描述: Web 启动类<br>
 * 版权所有: <br>
 * <P>
 * 创建者: 王建栋 <br>
 * 创建日期: 2015年12月16日 下午3:41:56<br>
 * 修改者: <br>
 * 修改日期: <br>
 * 修改说明: <br>
 *****************************************************************************
 */
@Order(1)
public class WebInitializer extends AbstraceWebInitializer {

	
	@Override
	protected Class<?>[] getRootConfigClasses() {
		return new Class[]{RootConfig.class};
	}
	
	@Override
	protected String[] getRootConfigLocations(){
		return new String[]{"com.dc.extended.config.root.RootConfig"};
	}

	/**
	 * 
	 */
	@Override
	protected Class<?>[] getServletConfigClasses() {
		return new Class[]{WebMvcConfig.class};
	}
	
	protected String[] getServletConfigLocations(){
		return new String[]{"com.dc.extended.config.mvc.WebMvcConfig"};
	}
	
	@Override
	protected String[] getServletMappings() {
		return new String[]{"/dwr/*","*.htm","*.json","*.jsonp"};
	}
	
	@Override
	public String[] getShiroExtendsMapping(){
		return new String[]{"/druid/*"};
	}
	
	
	
	
	
	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {
		super.onStartup(servletContext);
		super.addShiroFilter(servletContext);
	}


	/**
	 * 监听，现在什么都没有做，
	 */
	@Override
	protected ContextLoaderListenerWrapper getContextLoaderListenerWrapper() {
		 return new ContextLoaderListenerWrapperAdpater() {

			@Override
			public void afterContextInitialized(ContextLoaderListener contextLoaderListener,
					ServletContextEvent event) {
				System.out.println("afterContextInitialized check the License ");
			}

			@Override
			public void beforContextInitialized(ContextLoaderListener contextLoaderListener,
					ServletContextEvent event) {
				System.out.println("beforContextInitialized make the Data");
			}
			
		};
	}


}
